<?php
//Démarrage de la session
session_start();
	
$id = $_GET['id'];

//Connexion à la BDD
mysql_connect("localhost", "shop", "bb38f22jmtJQQZGG");
mysql_select_db("vanadium");mysql_query("SET NAMES 'UTF8'");

$id_shop = $_SESSION['id_shop_connecte'];

$retour_idshop = mysql_query("SELECT id FROM shop WHERE id_shop='$id_shop'") or die(mysql_error()) ;
$idshop = mysql_fetch_array($retour_idshop);
$idshop = $idshop['id'];
$retour_categorie = mysql_query("SELECT * FROM categories_produits WHERE id='$id' AND id_shop='$idshop' ") or die(mysql_error()) ;
$categorie = mysql_fetch_array($retour_categorie);
$retour_max_tab = mysql_query("SELECT place_tab FROM categories_produits WHERE id_shop='$idshop' ORDER BY place_tab DESC LIMIT 1") or die(mysql_error()) ;
$max_tab = mysql_fetch_array($retour_max_tab);

//Fermeture de la connexion
mysql_close();

echo"
<div id='edition_cat'>
	<h1>Edition de la Catégorie</h1>
	<form method='POST' action='../commun_shop/modules/traitement_modif_categorie.php' name='modif'>
		<input type='hidden' name='id_cat' value='$id'/>
		<table>
			<tr>
				<td>Nom de la catégorie : </td>
				<td><input type='text' name='nom_cat' value='".$categorie['categorie']."'/></td>
			</tr>
			<tr>
				<td>Placement Onglet</td>
				<td>
					<select name='place_tab'>";
				
					for($i=1;$i <= $max_tab['place_tab'];$i++) 
					{
						if($i==$categorie['place_tab'])
						{
							echo "<option value='$i' selected='selected'>$i</option>";
						}
						else
						{
							echo "<option value='$i'>$i</option>";
						}	
					}

echo"
					</select>
				</td>
			</tr>
		</table>
		<input type='submit' name='validation' value='Modifier' id='bouton'/>
	</form>
</div>
";
?>